﻿using B.S.DataBase.MyProject.Domain.HealthMonitoring;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Write.API.Appcation.Commands.HealthMonitoringCommand;
using MedicalPCTerminal.Write.API.Appcation.Commands.Management;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MedicalPCTerminal.Write.API.Controllers
{
    /// <summary>
    /// 健康监测-写
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HealthMonitoringControllers : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public HealthMonitoringControllers(IMediator mediator)
        {
            this.mediator = mediator;
        }

        #region BMI

        /// <summary>
        /// 添加BMI
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> AddBMI(AddBMIMonitoringCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除BMI
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<object>> DelBMI(DelReportsCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改BMI
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdateBMI(UpdateBMIMonitoringCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion
        #region 血压
        /// <summary>
        /// 添加血压信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> AddBloodPressure(AddBloodPressureCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除血压信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> DelBloodPressure(DelBloodPressureCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改血压
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdateBloodPressure(UpdateBloodPressureCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion


        #region 血糖
        /// <summary>
        /// 添加血糖信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> AddBloodSugar(AddBloodSugarCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除血糖信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> DelBloodSugar(DelBloodSugarCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改血糖
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdateBloodSugar(UpdateBloodSugarCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion
    }
}
